
import {DECREASE,INCREASE} from './reducers-type'
/**
 * action的工厂函数，包含所有的action creator
 * action的中的type字段是固定的是固定的:{type:'',data:''}
 * 同步action 返回的是一个对象
 * 异步的action返回一个函数
 * 
 * @param  number 
 */
export const increase = (number) =>({
    type:INCREASE,data:number
});
export const decrease = (number) =>({
    type:DECREASE,data:number
});
export const decreaseAsync = (number) => {
    return dispatch =>{
        //异步代码
        setTimeout(() =>{
            // 1s之后分发一个增加的action
            dispatch(increase(number))
        },1000)
    }
}